Skip to content

8361712: Improve ShenandoahAsserts printing #26237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

tstuefe
Copy link
Member

@tstuefe tstuefe commented Jul 10, 2025

Small changes to ShenandoahAsserts and friends to improve fault-tolerance and usefulnes:

  • In assert_correct, we now check the forwarding pointer first before extracting the narrowKlass from it. The forwarding pointer may be invalid. To do this, the forwarding-pointer-checking-block was moved up to before Klass* checks. We also use SafeFetch-based checks for some added safety.
  • In assert_correct, we test the narrowKlass before decoding it. Otherwise, if its 0, we'd assert, if garbage, the resulting Klass* would be garbage.
  • In print_failure, we now check pointers for readability before handing them to print_obj
  • In print_obj, we now print the extracted narrowKlass, too (useful on Lilliput with its terse ids)
  • In print_obj, we print a small hex dump of the header (32bytes). With little cost we get a glance at the raw header and the first members.
  • In print_obj, we print to a single stringStream now and use auto indentation. Avoids having to deal with indentation and newlines manually and having to pay for four stringStreams.
  • In assert_correct, I raised the print level for some of the klass-related assertions to safe_oop since the oop, since the hardened version of print_obj now avoids tripping over invalid Klass*

Tests: I manually tested the patch with a number of manually broken oops of various flavours.

Example output, invalid forwardee:

Referenced from:
  no interior location recorded (probably a plain heap scan, or detached oop)

Object:
  0x00000007cd800000 - nk 1798104 klass 0x00000000921b6fd8 [Ljava.lang.Object;

        allocated after mark start
        after update watermark
        marked strong
        marked weak
    not in collection set
    mark:  marked(0xdeaddeaddeaddeaf)
    region: | 3812|R  |Y|BTE    7cd800000,    7cd920bf8,    7cdc00000|TAMS    7cd800000|UWM    7cd800000|U  1154K|T     0B|G     0B|S  1154K|L     0B|CP   0

  0x00000007cd800000:   deaddeaddeaddeaf 00000a96001b6fd8 f9b005cff9b0054d f9b006d3f9b00651   .........o......M.......Q.......
  0x00000007cd800020:   f9b00797f9b00755 f9b00992f9b0087d f9b009a0f9b00999 f9b009a7f9b0098e   U.......}.......................

Forwardee:
  0xdeaddeaddeaddeac - safe print, no details

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8361712: Improve ShenandoahAsserts printing (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26237/head:pull/26237
$ git checkout pull/26237

Update a local copy of the PR:
$ git checkout pull/26237
$ git pull https://git.openjdk.org/jdk.git pull/26237/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26237

View PR using the GUI difftool:
$ git pr show -t 26237

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26237.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 10, 2025

👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 10, 2025

@tstuefe This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8361712: Improve ShenandoahAsserts printing

Reviewed-by: rkennke

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 71 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Jul 10, 2025

@tstuefe The following labels will be automatically applied to this pull request:

  • hotspot
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Jul 10, 2025
@tstuefe tstuefe changed the title assert_correct JDK-8361712: Improve ShenandoahAsserts printing Jul 10, 2025
@openjdk openjdk bot changed the title JDK-8361712: Improve ShenandoahAsserts printing 8361712: Improve ShenandoahAsserts printing Jul 10, 2025
@tstuefe tstuefe closed this Jul 11, 2025
@tstuefe tstuefe reopened this Jul 11, 2025
@tstuefe tstuefe force-pushed the harden-shenandoah-asserts branch from 63b1f4c to aab9d9c Compare July 11, 2025 14:42
@tstuefe tstuefe marked this pull request as ready for review July 12, 2025 06:39
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 12, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 12, 2025

Webrevs

Copy link
Contributor

@rkennke rkennke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really useful! I have only two comments/questions.

@tstuefe
Copy link
Member Author

tstuefe commented Jul 23, 2025

@rkennke Did I address all your concerns? Anyone else willing to look at this, @earthling-amzn maybe?

@rkennke
Copy link
Contributor

rkennke commented Jul 23, 2025

@rkennke Did I address all your concerns? Anyone else willing to look at this, @earthling-amzn maybe?

Yes, looks all good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review shenandoah shenandoah-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

2 participants